package com.lin.spring.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

/**
 * @ClassName AnnoationAop
 * @Description annoationAop
 * @Author lin
 * @Date 2021/11/10 下午10:40
 * @Version V1.0
 */
@Component
@Aspect
public class AnnoationAop {

    @Pointcut("execution(* com.lin.spring.aop.AccountService.accountSave())")
    public void pointCut1(){}

    @Pointcut("execution(* com.lin.spring.aop.AccountService.accountTake())")
    public void pointCut2(){}

    @Before("pointCut1()")
    public void before(){
        System.out.println("这是注解的前置通知");
    }

    @After("pointCut2()")
    public void after(){
        System.out.println("这是注解的后置通知");
    }

    @Around("pointCut1()")
    public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("这是注解的环绕通知--前");
        proceedingJoinPoint.proceed();
        System.out.println("这是注解的环绕通知--后");
    }
}
